<extend name="Base/common"/>

<block name="style">
<link href="__CSS__/product_stylesheet.css" rel="stylesheet">
<link href="__CSS__/pzb_stylesheet.css" rel="stylesheet">
</block>

<block name="script">
<link href="__STATIC__/jqzoom/css/jqzoom.css" rel="stylesheet">
<script type="text/javascript" src="__STATIC__/jqzoom/js/jquery.jqzoom.js"></script>
<script type="text/javascript" src="__JS__/pzb_product.js"></script>
</block>

<block name="header">
<header class="auction">
	<div class="container">
		<div class="logo fl"><img src="__IMG__/pzb/logo.png"></div>
		<div class="sub-nav fl">
			<ul>
	       		<li><a href="{:U('Pzb/index')}">首页</a></li>
	       		<li><a href="{:U('Pzb/index',array('extend'=>'begin'))}">即将开始</a></li>
	       		<li><a href="{:U('Pzb/index',array('extend'=>'end'))}">马上结束</a></li>
	       		<li><a href="{:U('Pzb/index',array('extend'=>'zero'))}">0元起拍</a></li>
	       	</ul>
		</div>
		<div class="search">
			<form action="" method="post" autocomplete="off">
	            <input name="title" class="search-input" placeholder="搜索拍品">
	            <a href="javascript:;" class="search-btn fr">搜索</a>
            </form>
        </div>
	</div>
</header>
</block>

<block name="body">
<div class="container main">
	<div class="col-xs-9" style="background-color: #ffffff;">
		<div class="row">
			<ul class="breadcrumb" style="background-color: #f5f5f5;">
				<li>当前位置</li>
				<li><a href="{:U('Index')}">首页</a></li>
				<li><a href="javascript:;">
					<eq name="info['is_stop']" value="1">
					已经停止
					<else />
					正在进行
					</eq>
				</a></li>
				<li>商品详情</li>
			</ul>
			<form action="__SELF__" method="post" class="form-horizontal" enctype="multipart/form-data">
				<div class="product-description">
					<div class="product-img">
						<div class="product-img-curr jqzoom">
						<volist name="info['images']" id='vo'  offset="0" length="1">
							<img src="{$vo.path}" jqimg="{$vo.path}" />
						</volist>
						</div>						
						<ul class="product-img-thumbs">	
							<volist name="info['images']" id='vo' key="key">
							<li <eq name='key' value='1'>class="selected" </eq>>
								<a href="javascript:;"><img src="{$vo.path}" /></a></li>
							</volist>													
						</ul>
					</div>
					<div class="product-info">
						<div class="product-info-hd">
							<h1>{$info.title}</h1>
						</div>
						<div class="product-info-panel">
							<dl class="product-info-panel-desc">
								<dt><span class="red-addon">正在进行</span></dt>
								<dd>
									<p>
										<span class="time" 
										starttime="{$info.start_time|time_format='m/d/Y H:s:m'}"
										 endtime="{$info.end_time|time_format='m/d/Y H:s:m'}">距离结束仅剩：
										 <em class="num">00</em>天<em class="num">7</em>时<em class="num">40</em>分</span>
									</p>
									<p>
										<span class="join"><em class="num">{$info.signupcount}</em>人已报名</span>
										<span class="view"><em class="num">{$info.view}</em>次围观</span>
									</p>
								</dd>
							</dl>
							<dl class="product-info-panel-price curr_price">
								<dt>当前价:</dt>
								<dd>
									<em class="yen">￥</em>
									<em class="price">{$info.top_price|number_format=2}</em>
									<span class="quantity">出价<em class="num">{$info.bidcount}</em>次</span>
								</dd>
							</dl>
						</div>
						 <eq name="info['is_auaction_permission']" value="1">
						 <else />
							 <eq name="info['is_stop']"  value="1">
								  <div class="product-info-action">
									<a class="btn" href="javascript:;">本次竞拍已结束</a>
								 </div>
							 <else />
								 <div class="product-info-action">
									<a class="btn join" href="javascript:;">交保证金报名</a>
								 </div>
							 </eq>						
						 </eq>					
						
						 <div class="product-info-action">
						  <eq name="info['is_auaction_permission']" value="1">						 
						    <dl class="product-info-action-bond my_bid">
							 	<dt>我的上次出价:</dt>
								<dd>
									<em class="yen">￥</em>
									<em class="price">0.00</em>
									<span class="status in"></span>
								</dd>
							</dl>
						  </eq>
						   <eq name="info['is_auaction_permission']" value="1">
							   <eq name="info['is_stop']" value="1">
							   <else />
							   <input type="text" class="input" value="" name="bid_price" placeholder="元">
								<a class="btn bond" href="javascript:;">出价</a>
							   </eq>
							</eq>							
								
								<eq name="is_confirm" value="0">
								<a class="btn"  href="{:U('save',array('id'=>$info['id']))}" >去结算</a>
								<else />
								<a class="btn"  href="{:U('save',array('id'=>$info['id']))}"  id="comfirmId" style="display:none">去结算</a>
								</eq>
							
						</div>
						<script>
							var pid={$info.id};
							var is_stop=parseInt({$info.is_stop});
							function bidFresh(){
								
								$.get("{:U('currentInfo')}",{id:pid},function(data){
									if(data.status==1){
										var result=data.result;
										//报名人数
										$('.product-info-panel-desc > dd > .join > .num').html(result.signupcount);
										//围观人数
										$(".product-info-panel-desc  > dd > .view > .num").html(result.view);
										//当前出价
										$(".curr_price  > dd > .price").html(result.price);
										//当前出价次数
										$(".curr_price  > dd > .quantity > .num").html(result.auction_no);
										//我的报价
										$(".my_bid  > dd > .price").html(result.my_bid_price);
										
										//出价记录 条数
										$(".bound_count > em").html("("+result.auction_no+")");
										
										if(result.my_first==1){
											$(".my_bid  > dd span").addClass('in');
											$(".my_bid  > dd span").html('领先');
										}else{
											$(".my_bid  > dd span").removeClass('in');
											$(".my_bid  > dd span").html('出局');
										}
									}
									else{
										$(".product-info-action-bond").find('dt').html('未参与竞拍');
										$(".my_bid  > dd span").html('无出价');
									}
								});
								if(is_stop==1){
									return;
									location.reload();
								}
								timer = setTimeout("bidFresh()", 10000);
								
							}									
							bidFresh();	
							
							$(function(){								
								$(".join").click(function(){
									$.get("{:U('paipinSignup')}",{product_id:pid},function(data){
										if(data.status){
											updateAlert(data.info);
											location.reload();
										}else{
											updateAlert(data.info);
											updateAlert(data.info);
										}
									});
								});
								$(".bond").click(function(){
									if(is_stop==1){
										updateAlert('竞拍已结束');
										location.reload();
									}
									var re=new RegExp("^[1-9]+[0-9]*");
									
									var bid_pice=$("input[name='bid_price']").val();
									var curr_price=$(".curr_price .price").html();
								
									if(!re.test(bid_pice)){
										updateAlert('出价格式错误');
									}else{									
										if(parseInt(bid_pice) < parseInt(curr_price)){
											updateAlert('出价不能低于当前最高出价');
										}
										$.get("{:U('bid')}",{product_id:pid,money:bid_pice},function(data){
											if(100==parseInt(data.status)){
												updateAlert(data.info);
												$('#comfirmId').show();
												return;
											}else if(data.status){
												updateAlert('出价成功');
											}											
											else{
												updateAlert(data.info);
											}
										});
									}
								});
							});
							</script>
							
						<div class="product-info-bid">
							<span>起拍价：￥{$info.price_start}</span>
							<span>一口价：￥{$info.maxprice}</span>
							<span>保证金：￥{$info.cash_deposit}</span>
						</div>
					</div>
				</div>
			</form>
			<ul class="tab-bar">
				<li><a href="#description" class="selected">商品描述</a></li>
				<li><a href="#bondlog" class="bound_count">出价记录<em>（{$info.bidcount}）</em></a></li>
				<li><a href="#bond">保证金须知</a></li>
			</ul>
			<div class="tab-panel active" id="description">
				{$info.description}
			</div>
			<div class="tab-panel" id="bondlog">
				<div class="bondlogs">
					<div class="hd">
						<span>状态</span>
						<span>出价</span>
						<span>竞拍人</span>
						<span>时间</span>
					</div>
					<ul class="bd">
						<li class="active">
							<span>领先</span>
							<span>￥2020.00</span>
							<span>项***环</span>
							<span>2015-10-12 10:45</span>
						</li>
					</ul>
					<div class="page center" data-url="{:U('Pzb/getBondlogs',array('product_id'=>$info['id']))}"></div>
				</div>
			</div>
			<div class="tab-panel" id="bond">
				保证金
			</div>
		</div>
	</div>
	<div class="col-xs-3 hot">
		<h5>拍品推荐</h5>
		<volist name="delicacy_list" id="vo">
			<div class="form-group auto-overflow">
				<a href="{:U('auctionDetail',array('id'=>$vo['id']))}"><img src="__ROOT__{$vo.image}" /></a>
				<div class="fl info">
					<div class="title"><a href="{:U('auctionDetail',array('id'=>$vo['id']))}">{$vo.title}</a></div>
					<div class="desc">
						<div class="bids"><a href="{:U('auctionDetail',array('id'=>$vo['id']))}" class="btn">
						{$vo.auction_count}次出价</a></div>
						<div class="time endtime" starttime="{$vo.start_time|time_format='m/d/Y H:s:m'}" 
						endtime="{$vo.end_time|time_format='m/d/Y H:s:m'}"></div>
					</div>
				</div>
			</div>
		</volist>	
	</div>
</div>
</block>